#ifndef _RandomSpin_H_
#define _RandomSpin_H_

//
// RandomSpin.h
//
// Created by TB on 11/23/11.
// Copyright 2011 BNL. All rights reserved.
//

#include "tppmc/Particle.h"

namespace tppmc {
   
   class PartonDistribution;
//   class pythpart;
   
   /**
    Randomly select a spin state based on an input unpolarised and
    polarised parton distribution.
    */
   class RandomSpin {
      
   public:
      
      /**
       Initialise with the unpolarised and polarised distributions.
       The referenced objects must have a lifetime greater than
       the RandomSpin object.
       */
      RandomSpin(PartonDistribution* unpolarised,
                 PartonDistribution* polarised);
      
      virtual ~RandomSpin();
      
      /**
       Randomly generate a spin state for the input parton flavour,
       kinematics and interaction scale.
       Returns -1 for a parton spin opposite the proton spin direction,
       +1 for a parton spin parallel to the proton spin direction and
       0 for no polarisation (in the event of zero (un)polarised
       distribution).
       */
      virtual int Generate(const pythpart&, double scale) const;
      
   protected:
      
      PartonDistribution* mUnpolarised;
      PartonDistribution* mPolarised;
   };
   
} // namespace tppmc

#endif
